package com.r2coding.article.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.r2coding.article.vo.req.CommentReqVo;
import com.r2coding.article.vo.resp.MessageRespVo;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.r2coding.article.dao.MessageDao;
import com.r2coding.article.entity.MessageEntity;
import com.r2coding.article.service.MessageService;

import java.util.List;

/**
 * 留言
 *
 * @author 98k灬
 * @email hk666zx@163.com
 * @date 2022-06-04 00:37:57
 */
@Service("messageService")
public class MessageServiceImpl extends ServiceImpl<MessageDao, MessageEntity> implements MessageService {

    @Override
    public MessageRespVo listMessage(CommentReqVo req) {
        MessageRespVo respVo = new MessageRespVo();
        Integer count = this.baseMapper.selectCount(null);
        respVo.setTotal(count);
        PageHelper.startPage(req.getCurrent(), req.getSize());
        QueryWrapper<MessageEntity> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("create_time");
        List<MessageEntity> list = this.baseMapper.selectList(wrapper);
        respVo.setList(list);
        return respVo;
    }
}